package thread;

public class SynchronizedTest1 extends Thread {
    static  int a = 0;

    public static void main(String[] args) throws InterruptedException {
        SynchronizedTest1 noSynchronizedTest = new SynchronizedTest1();
        SynchronizedTest1 noSynchronizedTest1 = new SynchronizedTest1();
        noSynchronizedTest.start();
        noSynchronizedTest1.start();
        noSynchronizedTest.join();
        noSynchronizedTest1.join();
        System.out.println(a);
    }
    
    public   void add(){
        System.out.println(Thread.currentThread().getName());



        synchronized (SynchronizedTest1.class) {
            for (int i = 0; i < 10000; i++) {
                a++;
            }
        }
    }
    @Override
    public void run() {
            add();

    }
}
